/*
 *******************************************************************************
 *
 * Copyright (C) 2019-2020 Dialog Semiconductor.
 * This computer program includes Confidential, Proprietary Information
 * of Dialog Semiconductor. All Rights Reserved.
 *
 *******************************************************************************
 */

package com.dialog.suotalib.global;

import android.annotation.SuppressLint;
import android.bluetooth.BluetoothGatt;
import android.os.Build;
import android.os.Environment;

import java.io.File;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;

public class SuotaLibConfig {

    // SuotaScanner Config
    public static final boolean ALLOW_DIALOG_DISPLAY = true;
    public static final boolean CHECK_PERMISSIONS = true;
    public static final boolean CHECK_LOCATION_WITH_PLAY_SERVICES = false;

    // Suota Manager and Protocol Config
    public static final boolean ACQUIRE_WAKELOCK = true;
    public static final boolean REQUEST_CONNECTION_PRIORITY = true;
    @SuppressLint("InlinedApi")
    public static final int CONNECTION_PRIORITY_UPLOAD = BluetoothGatt.CONNECTION_PRIORITY_HIGH;
    @SuppressLint("InlinedApi")
    public static final int CONNECTION_PRIORITY_NORMAL = BluetoothGatt.CONNECTION_PRIORITY_BALANCED;
    public static final boolean REFRESH_REQUIRED = Build.VERSION.SDK_INT < Build.VERSION_CODES.O;
    public static final boolean REFRESH_REQUIRED_IF_BONDED = true;
    /**
     * 链接超时刷新
     */
    public static final boolean REFRESH_ON_CONNECTION = true;
    public static final boolean REFRESH_AFTER_UPDATE = true;
    public static final boolean CHECK_HEADER_CRC = true;
    public static final boolean CALCULATE_STATISTICS = true;
    public static final int UPLOAD_TIMEOUT = 30000; // ms
    public static final boolean AUTO_REBOOT = false;
    public static final boolean AUTO_DISCONNECT_IF_REBOOT_DENIED = false;
    public static final boolean AUTO_READ_DEVICE_INFO = true;
    public static final boolean READ_DEVICE_INFO_FIRST = true;
    public static final boolean READ_ALL_DEVICE_INFO = false;
    public static final boolean NOTIFY_DEVICE_INFO_READ = true;
    public static final boolean NOTIFY_DEVICE_INFO_READ_COMPLETE = true;
    public static final boolean NOTIFY_SUOTA_LOG = true;
    public static final boolean NOTIFY_SUOTA_LOG_CHUNK = false;
    public static final boolean NOTIFY_SUOTA_LOG_BLOCK = false;
    public static final boolean NOTIFY_CHUNK_SEND = true;
    public static final boolean NOTIFY_BLOCK_SENT = true;
    public static final boolean NOTIFY_UPLOAD_PROGRESS = true;
    public static final boolean GATT_CALLBACK_USE_BINDER_THREAD = false;
    public static final boolean PROTOCOL_DEBUG = false;
    public static String fileName="";
    public static String mkDir="";
    public static final List<UUID> DEVICE_INFO_TO_READ = Arrays.asList(
            SuotaProfile.Uuid.CHARACTERISTIC_MANUFACTURER_NAME_STRING,
            SuotaProfile.Uuid.CHARACTERISTIC_MODEL_NUMBER_STRING,
            SuotaProfile.Uuid.CHARACTERISTIC_FIRMWARE_REVISION_STRING,
            SuotaProfile.Uuid.CHARACTERISTIC_SOFTWARE_REVISION_STRING);
    public static String getFileName() {
        return fileName;
    }

    public static void setFileName(String fileName) {
        SuotaLibConfig.fileName = fileName;
    }
    public static String getMkDir() {
        return mkDir;
    }

    public static void setMkDir(String mkDir) {
        SuotaLibConfig.mkDir = mkDir;
    }

    public static class Default {

        public static final long SCAN_TIMEOUT = 10000; // ms

        public static final String FIRMWARE_PATH = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "Suota";
        public static final boolean FILE_LIST_HEADER_INFO = false;

        public static final int BLOCK_SIZE = 240;
        public static final int CHUNK_SIZE = 20;
        public static final String SDPATH = Environment.getExternalStorageDirectory().getAbsolutePath()+"/ring/";
//        public static String SDPATH = "toall.ring/";
        public static final int IMAGE_BANK = SuotaProfile.Constants.IMAGE_BANK_OLDEST;

        // Default memory type
        public static final int MEMORY_TYPE = SuotaProfile.Constants.MEMORY_TYPE_EXTERNAL_SPI;

        // Default SPI memory settings
        public static final int MISO_GPIO = 0x05;
        public static final int MOSI_GPIO = 0x06;
        public static final int CS_GPIO = 0x03;
        public static final int SCK_GPIO = 0x00;

        // Default I2C memory settings
        public static final String I2C_DEVICE_ADDRESS = "0x50";
        public static final int SCL_GPIO = 0x02;
        public static final int SDA_GPIO = 0x03;
    }
}
